package com.fh.common.exceptions;

import com.fh.common.baseData.TongyiData;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author SXL
 * @version 1.0.0
 * @ClassName ControllerExeceptions.java
 * @Description TODO
 * @createTime 2021年12月09日 09:06:00
 */
@RestControllerAdvice
public class ControllerExeceptions {
    /*  处理空指针异常 */
    @ExceptionHandler(NullPointerException.class)
    public TongyiData chandleNullPoinExceptions(Exception e){
        e.printStackTrace();
        return TongyiData.error(500,"出现空指针了");
    }
    /*  处理空指针异常*/
    @ExceptionHandler(ArithmeticException.class)
    public TongyiData chandleArithmeticException(Exception e){
        e.printStackTrace();
        return TongyiData.error(500,"0 bun");
    }

    /*  处理空指针异常*/
    @ExceptionHandler(Exception.class)
    public TongyiData chandleException(Exception e){
        e.printStackTrace();
        return TongyiData.error(500,"未处理的异常:"+e.getMessage());
    }
}
